import { IsOptional, IsNumber, IsString, IsEnum, Min } from "class-validator";
import { Type } from "class-transformer";
import { Gender } from "../../enum/gender.enum";

/**
 * 用户查询参数DTO
 */
export class UserQueryDto {
  @IsOptional()
  @Type(() => Number)
  @IsNumber({}, { message: "页码必须是数字" })
  @Min(1, { message: "页码必须从1开始" })
  page?: number;

  @IsOptional()
  @Type(() => Number)
  @IsNumber({}, { message: "每页数量必须是数字" })
  @Min(1, { message: "每页数量必须大于0" })
  pageSize?: number;

  @IsOptional()
  @IsString({ message: "搜索关键词必须是字符串" })
  search?: string;

  @IsOptional()
  @IsEnum(Gender, { message: "性别必须是有效的枚举值" })
  gender?: Gender;

  @IsOptional()
  @Type(() => Number)
  @IsNumber({}, { message: "角色ID必须是数字" })
  roleId?: number;
}
